import java.util.Comparator;

public class Card implements Comparable<Card> {

	private String color;
	private int value;

	public Card(final String color, final int value) { // konstruktor klasy
		setColor(color);
		setValue(value);
	}

	public final String getColor() {
		return color;
	}

	public final int getValue() {
		return value;
	}

	public final boolean setColor(final String color) {
		if (color.equals("spade") == true || color.equals("heart") == true
				|| color.equals("diamond") == true
				|| color.equals("club") == true) {
			this.color = color;
			return true;
		} else {
			return false;
		}
	}

	public final boolean setValue(final int value) {
		if (value > 1 && value < 15) {
			this.value = value;
			return true;
		} else {
			return false;
		}
	}

	public final String getConvertedValue() {
		if (value > 10) {
			switch (value) {
			case 11:
				return "Knave of";
			case 12:
				return "Queen of";
			case 13:
				return "King of";
			case 14:
				return "Ace of";
			}
		} else {
			return Integer.toString(value);
		}
		return "This return is only for compiler";
	}

	public static Comparator<Card> ValueComparator = new Comparator<Card>() {

		public int compare(final Card card1, final Card card2) {

			Integer cardValue1 = card1.getValue();
			Integer cardValue2 = card2.getValue();
			// ascending order
			return cardValue1.compareTo(cardValue2);

			// descending order
			// return cardValue2.compareTo(cardValue1);
		}

	};

	@Override
	public final int compareTo(final Card comperCard) {
		int compareValue = comperCard.getValue();

		// ascending order
		return this.value - compareValue;

		// descending order
		// return compareValue - this.value;

	}

}
